home *** CD-ROM | disk | FTP | other *** search
/ DOpus Plus / DOpus Plus.iso / Enhancements / CutNPaste / Opus5 / modules / CutNPaste.dopus5
Encoding:
Text File  |  1998-10-21  |  4.9 KB  |  121 lines

  1. /* $VER: CutNPaste.dopus5 2.2SE (21.10.98)                         */
  2. /* Special Version for Opus Magellan II                            */
  3.  
  4. /* Cut & Paste module - Adds "Cut" and "Copy" to file pop-up menus */
  5. /* and "Paste" to lister pop-up menus.  Nothing is done until you  */
  6. /* Paste when the appropriate Copy or Move command is issued.      */
  7. /*                                          Andrew Dunbar Oct 1997 */
  8. /*                                          <andrew@gpsoft.com.au> */
  9.  
  10. /* Fixed problems with space in filenames and added locale support */
  11. /* and Danish catalog.                                             */
  12. /*                             Michael Skibsted Sørensen, Oct 1998 */
  13. /*                                                    <MSS@kob.dk> */
  14.  
  15. /* Added "Paste into" to directory pop-up menus and "Paste as.."   */
  16. /* and "Paste into as.." commands using CopyAs or MoveAs commands. */
  17. /* Added "View Clipboard Contents" and "Clear Clipboard Contents"  */
  18. /* commands + other minor changes.                                 */
  19. /*                                        Keith Halstead, Oct 1998 */
  20. /*                                           <cv51kh@surrey.ac.uk> */
  21.  
  22. /*  MULTIPLE FILE SUPPORT WILL BE AVAILABLE NOW! - CHECK AMINET!!  */
  23.  
  24. parse arg portname function source dest arguments
  25. address value portname
  26. options results
  27.  
  28. if ~show('l','rexxsupport.library') then
  29.   call addlib('rexxsupport.library',0,-30,0)
  30. if ~show(l,'locale.library') then
  31.   call addlib('locale.library',0,-30)
  32. if show(l,'locale.library') then
  33.   catalog = opencatalog('CutNPaste.catalog','english',0)
  34.  
  35. if function = 'init' then do
  36.   cnptypes = 'type drawer type tool type project type trash'
  37.   dopus command 'Clip-Copy' program 'CutNPaste' ext locale(1,'Copy') private cnptypes
  38.   dopus command 'Clip-Cut' program 'CutNPaste' ext locale(2,'Cut') private cnptypes
  39.   dopus command 'Clip-Paste' program 'CutNPaste' ext locale(3,'Paste') private type lister
  40.   dopus command 'Clip-PasteAs' program 'CutNPaste' ext locale(4,'Paste As...') private type lister
  41.   dopus command 'Clip-PasteInto' program 'CutNPaste' ext locale(5,'Paste Into') private type disk type drawer
  42.   dopus command 'Clip-PasteIntoAs' program 'CutNPaste' ext locale(6,'Paste Into As...') private type disk type drawer
  43.   dopus command 'Clip-View' program 'CutNPaste' ext locale(9,'View Clipboard Contents...') private type lister
  44.   dopus command 'Clip-Clear' program 'CutNPaste' ext locale(10,'Clear Clipboard Contents...') private type lister
  45. end
  46.  
  47. else if function = 'Clip-Clear' then do
  48.   if exists('T:clipcnp')=1 then command 'delete T:clipcnp quiet'
  49. end
  50.  
  51. else if function = 'Clip-View' then do
  52.   if open('cnpfile','T:clipcnp','r') then do
  53.     cnpinfo = "'"readln('cnpfile')"'"
  54.     call close('cnpfile')
  55.     parse var cnpinfo cmd ' ' srcfile
  56.     srcfile = trim(srcfile)
  57.     if srcfile ~= '' then dopus request locale(11,'Clipboard contents')||"': '"cnpinfo""
  58.     else dopus request locale(7,'Paste: Clipboard invalid')
  59.   end
  60.   else dopus request locale(8,'Paste: Nothing in clipboard')
  61. end
  62.  
  63. else if function = 'Clip-Cut' then address command 'echo >T:clipcnp cut 'arguments
  64.  
  65. else if function = 'Clip-Copy' then address command 'echo >T:clipcnp copy 'arguments
  66.  
  67. /* PASTE (AS) */
  68. if function = 'Clip-Paste' | function = 'Clip-PasteAs' then do
  69.   lister query source path
  70.   pastepath = result
  71.   call mainfunc
  72. end
  73.  
  74. /* PASTE INTO (AS) */
  75. if function = 'Clip-PasteInto' | function = 'Clip-PasteIntoAs' then do
  76.   pastepath = arguments
  77.   call mainfunc
  78. end
  79.  
  80. exit
  81.  
  82. locale:
  83.   parse arg msgno,msgstring
  84.  
  85.   if catalog ~= 0 then
  86.     msgstring = getcatalogstr(catalog,msgno,msgstring)
  87.  
  88.   do i = 3 to arg()
  89.     parse var msgstring before '%s' after
  90.     msgstring = before||arg(i)||after
  91.   end
  92. return '"'msgstring'"'
  93.  
  94. mainfunc:
  95.   if open('cnpfile','T:clipcnp','r') then do
  96.     cnpinfo = readln('cnpfile')
  97.     call close('cnpfile')
  98.     parse var cnpinfo cmd ' ' srcfile              /* Spaces in source name/path fixed */
  99.     srcfile = trim(srcfile)                        /* by Michael Skibsted Sørensen     */
  100.     if srcfile ~= '' then do
  101.       srcfile = '"'srcfile'"'
  102.       if function = 'Clip-Paste' | function = 'Clip-PasteInto' then do
  103.         if cmd = 'copy' then command wait copy 'name='srcfile 'to='pastepath
  104.         else if cmd = 'cut' then command wait move 'name='srcfile 'to='pastepath
  105.         if function = 'Clip-Paste' then lister read source pastepath force
  106.       end
  107.       else if function = 'Clip-PasteAs' | function = 'Clip-PasteIntoAs' then do
  108.         if cmd = 'copy' then command wait copyas 'name='srcfile 'to='pastepath
  109.         else if cmd = 'cut' then command wait moveas 'name='srcfile 'to='pastepath
  110.         if function = 'Clip-PasteAs' then lister read source pastepath force
  111.       end
  112.       if cmd = 'cut' then do
  113.         srcfile=compress(srcfile,'"')
  114.         if exists(srcfile)=0 then command 'delete T:clipcnp quiet'
  115.       end
  116.     end
  117.     else dopus request locale(7,'Paste: Clipboard invalid')
  118.   end
  119.   else dopus request locale(8,'Paste: Nothing in clipboard')
  120. return
  121.